module.exports = {
    nametransform: function(input) {
        return input && 1 < input.length ? input.slice(0, 1) : input;
    },
    formatDateTime: function(timestamp) {
        var date, month;
        return (timestamp = (date = timestamp ? new Date(1e3 * Number(timestamp)) : new Date()).getFullYear()) + "-" + (month = (month = date.getMonth() + 1) < 10 ? "0" + month : month) + "-" + ((date = date.getDate()) < 10 ? "0" + date : date);
    },
    strcharacterDiscode: function(input) {
        return (input = (input = (input = (input = (input = (input = input.replace(/&nbsp;/g, " ")).replace(/&quot;/g, "'")).replace(/&amp;/g, "&")).replace(/&lt;/g, "<")).replace(/&gt;/g, ">")).replace(/&#8226;/g, "•")).replace(/&nbsp;/g, " ").replace(/&nbsp;/g, " ");
    },
    formatDateTimehour: function(timestamp) {
        var year = (timestamp = timestamp ? new Date(1e3 * Number(timestamp)) : new Date()).getFullYear(), month = (month = timestamp.getMonth() + 1) < 10 ? "0" + month : month, day = (day = timestamp.getDate()) < 10 ? "0" + day : day, hour = (hour = timestamp.getHours()) < 10 ? "0" + hour : hour, minute = timestamp.getMinutes();
        return timestamp.getSeconds(), year + "-" + month + "-" + day + " " + hour + ":" + (minute < 10 ? "0" + minute : minute);
    },
    readingvolume: function(volume) {
        return 1e4 <= volume && (volume = (volume / 1e4).toFixed(2) + "万"), volume;
    },
    transtr: function(input) {
        return input.split(",");
    },
    formatImg: function(input) {
        return input.replace(/<img[^>]*>/gi, function(match, p1) {
            return (match = (match = match.replace(/style=[\'\"]?([^\'\"]*)[\'\"]?/i, "")).replace(/src=[\'\"]/i, function(match, p1) {
                return match + "https://e.zkezy.com/";
            })).replace(/src=[\'\"]?([^\'\"]*)[\'\"]?/gi, function(match, src) {
                return MyPreviewList.push(src), "onclick=\"mypreviewfun('" + src + "')\"" + match;
            });
        });
    },
    formatImgtwo: function(input) {
        return input.replace(/<img[^>]*>/gi, function(match, p1) {
            return match.replace(/src=[\'\"]/i, function(match, p1) {
                return match + "https://e.zkezy.com/";
            });
        });
    },
    transType: function(type) {
        var result = "";
        return 1 == type && (result = "普通考试"), 2 == type && (result = "报名考试"), 3 == type && (result = "固定人群考试"), 
        4 == type && (result = "付费考试"), 5 == type && (result = "密码考试"), 6 == type && (result = "VIP考试"), 7 == type && (result = "班级考试"), 
        result;
    },
    formatDateDayTimehour: function(targetTime) {
        var timeDifference;
        if (0 < (timeDifference = targetTime - (timeDifference = new Date().getTime()))) {
            var days = parseInt(timeDifference / 1e3 / 60 / 60 / 24, 10);
            return parseInt(timeDifference / 1e3 / 60 / 60 % 24, 10), parseInt(timeDifference / 1e3 / 60 % 60, 10), parseInt(timeDifference / 1e3 % 60, 10), 
            new Date(targetTime).toDateString() === new Date().toDateString() ? 0 : timeDifference < 86400 ? 1 : days + 1;
        }
        return 0;
    }
};